Conversation
f6d601a to
9eba2fc
Compare
9eba2fc to
5b95557
Compare
A typo in RSpec is typing `if` instead of `it`. Depending on the font, they can be hard to distinguish at a glance: ```ruby if "does something" do # Should be `it "does something" do` # ... end ``` This results in a confusing "Unmatched keyword, missing `end'?" error because both `if` and `do` require their own `end`. And some keywords like `while` and `loop` take `do`, so it's not always obvious that `if` or `unless` don't. The message needs to accommodate a scenario where it's unknown if the value inside accepts a block like: ```ruby if method_call do end ``` This might be perfectly valid ruby code, so you wouldn't want to assert "if does not take a do" (since that's not the problem...the problem is that both if and do require an `end` to close, but the code doesn't provide that). Before: ``` Unmatched keyword, missing `end' ? 2 describe "something" do > 3 if "does something" do > 5 end 6 end ``` After: ``` Unmatched keyword, missing `end' ? Both `if` and `do` require an `end`. 2 describe "something" do > 3 if "does something" do > 5 end 6 end ``` Close #206
5b95557 to
a4c04e6
Compare
|
I don't have much expertise but
In the rspec case, you can't insert But I don't have an idea how to spell it differently. |
|
Thanks for the look!
Good call. I'm also not sure how to make it better either, but I'll think on it. One option could be specializing it for literals (strings, arrays, numbers), those are reliably detectable, but any bareword could be a method. Curly brackets One general difficulty of working in the "we expect to see messed-up source code" space is trying to divine intent from input that we already know is wrong in at least one way. |
A typo in RSpec is typing
ifinstead ofit. Depending on the font, they can be hard to distinguish at a glance:This results in a confusing "Unmatched keyword, missing 'end'?" error because both
ifanddorequire their ownend. And some keywords likewhileandlooptakedo, so it's not always obvious thatiforunlessdon't.The message needs to accommodate a scenario where it's unknown if the value inside accepts a block like:
This might be perfectly valid ruby code, so you wouldn't want to assert "if does not take a do" (since that's not the problem...the problem is that both if and do require an
endto close, but the code doesn't provide that.Before:
After:
Close #206